package com.wiloon.androidx.json;


import com.wiloon.androidx.MainActivity;

import org.apache.log4j.Logger;

import java.lang.reflect.Type;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by wangyue on 8/27/2014.
 */
public class Gsonx {
    private static final Logger logger = Logger.getLogger(MainActivity.class);

    public static void test() {
//        GsonBuilder gsonBuilder = new GsonBuilder();
//        // Register customized DateTypeAdapter
//        // set html code disable
//        gsonBuilder.disableHtmlEscaping();
//        gsonBuilder.registerTypeAdapter(Date.class, new MillisecondsDateTypeAdapter());
//        Map map = new HashMap();
//        map.put("funName", "GetAndroidVersion");
//        map.put("serialVersionUID", -4308869841788373801l);
//        map.put("language", "zh");
//        map.put("APPVersion", "1.1.1");
//        map.put("funName", "GetAndroidVersion");
//        map.put("funName", "GetAndroidVersion");
//        map.put("funName", "GetAndroidVersion");
//        map.put("funName", "GetAndroidVersion");
//        String json = gsonBuilder.create().toJson(map);
//        logger.debug("json:" + json);


    }

//    public static class MillisecondsDateTypeAdapter implements JsonSerializer<Date>, JsonDeserializer<Date> {
//
//        @Override
//        public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
//            return new JsonPrimitive(src.getTime());
//        }
//
//        @Override
//        public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
//                throws JsonParseException {
//            return new Date(json.getAsLong());
//        }
//
//    }
}
